<?php
if(!defined('IN_WOGU')) {
    exit('Access Denied');
}

Loader::loadClass('Model');

class BlockTemplateModel extends Model
{
    protected $_table = 'block_template';

    public function addTpl($data) {
        return $this->insert($data, true);
    }
    
    public function getTpl($where) {
        $tpl = $this->getOne($where);
        if($tpl) {
            $tpl['tpl_fields'] = unserialize($tpl['tpl_fields']);
        }
        
        return $tpl;
    }
    
    public function deleteTpl($id) {
        $this->delete(array('id' => $id));
    }
    
    public function updateTpl($data, $where) {
        return $this->update($data, $where);
    }
    
    public function listTpls($where, $page = 1, $perpage = 30, $order = 'id ASC') {
        Loader::loadClass('Page');
        return $this->listInfo($where, $page, $perpage, $order, '');
    }
    
    public function getTpls($where = '', $data = '*') {
        return $this->select($where, $data, '', 'id ASC', '', 'id');
    }
}